//-
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

include /app/helpers/jade/mixins
include /app/configuration/mixins

-var form = 'misc'
-var model = '$ctrl.clonedCluster'

panel-collapsible(ng-form=form on-open=`ui.loadPanel('${form}')`)
    panel-title Miscellaneous
    panel-description Various miscellaneous cluster settings.
    panel-content.pca-form-row(ng-if=`ui.isPanelLoaded('${form}')`)
        .pca-form-column-6.pc-form-grid-row
            .pc-form-grid-col-60
                +form-field__text({
                    label: 'Work directory:',
                    model: `${model}.workDirectory`,
                    name: '"workDirectory"',
                    placeholder: 'Input work directory',
                    tip: 'Ignite work directory.<br/>\
                          If not provided, the method will use work directory under IGNITE_HOME specified by IgniteConfiguration#setIgniteHome(String)\
                          or IGNITE_HOME environment variable or system property.'
                })
            .pc-form-grid-col-60
                +form-field__text({
                    label: 'Ignite home:',
                    model: `${model}.igniteHome`,
                    name: '"igniteHome"',
                    placeholder: 'Input ignite home directory',
                    tip: 'Ignite installation folder'
                })
            .pc-form-grid-col-60
                mixin life-cycle-beans()
                    .ignite-form-field
                        -let items = `${model}.lifecycleBeans`;

                        list-editable(
                            ng-model=items
                            list-editable-cols=`::[{
                                name: 'Lifecycle beans:',
                                tip: 'Collection of life-cycle beans.\
                                These beans will be automatically notified of grid life-cycle events'
                            }]`
                        )
                            list-editable-item-view {{ $item }}

                            list-editable-item-edit
                                +list-java-class-field('Bean', '$item', '"bean"', items)
                                    +form-field__error({
                                        error: 'igniteUnique',
                                        message: 'Bin with such class name already configured!'
                                    })

                            list-editable-no-items
                                list-editable-add-item-button(
                                    add-item=`$editLast((${items} = ${items} || []).push(""))`
                                    label-single='Bean'
                                    label-multiple='Beans'
                                )

                - var form = '$parent.form'
                +life-cycle-beans
                - var form = 'misc'
            .pc-form-grid-col-60
                +form-field__java-class({
                    label: 'Address resolver:',
                    model: `${model}.addressResolver`,
                    name: '"discoAddressResolver"',
                    tip: 'Address resolver for addresses mapping determination'
                })
            .pc-form-grid-col-60
                +form-field__java-class({
                    label: 'MBean server:',
                    model: `${model}.mBeanServer`,
                    name: '"mBeanServer"',
                    tip: 'MBean server'
                })
            .pc-form-grid-col-60
                .ignite-form-field
                    +list-text-field({
                        items: `${model}.includeProperties`,
                        lbl: 'Include properties',
                        name: 'includeProperties',
                        itemName: 'property',
                        itemsName: 'properties'
                    })(
                    list-editable-cols=`::[{
                            name: 'Include properties:',
                            tip: 'System or environment property names to include into node attributes'
                        }]`
                    )
                        +form-field__error({error: 'igniteUnique', message: 'Such property already exists!'})
            .pc-form-grid-col-60
                mixin store-session-listener-factories()
                    .ignite-form-field
                        -let items = `${model}.cacheStoreSessionListenerFactories`;

                        list-editable(
                            ng-model=items
                            list-editable-cols=`::[{
                                name: 'Store session listener factories:',
                                tip: 'Default store session listener factories for all caches'
                            }]`
                        )
                            list-editable-item-view {{ $item }}

                            list-editable-item-edit
                                +list-java-class-field('Listener', '$item', '"Listener"', items)
                                    +form-field__error({
                                        error: 'igniteUnique',
                                        message: 'Listener with such class name already exists!'
                                    })

                            list-editable-no-items
                                list-editable-add-item-button(
                                    add-item=`$editLast((${items} = ${items} || []).push(""))`
                                    label-single='listener'
                                    label-multiple='listeners'
                                )

                - var form = '$parent.form'
                +store-session-listener-factories
                - var form = 'misc'
            //- Since ignite 2.0
            .pc-form-grid-col-60(ng-if-start='$ctrl.available("2.0.0")')
                +form-field__text({
                    label: 'Consistent ID:',
                    model: `${model}.consistentId`,
                    name: '"ConsistentId"',
                    placeholder: 'Input consistent ID',
                    tip: 'Consistent globally unique node ID which survives node restarts'
                })
            .pc-form-grid-col-60(ng-if-end)
                +form-field__java-class({
                    label: 'Warmup closure:',
                    model: `${model}.warmupClosure`,
                    name: '"warmupClosure"',
                    tip: 'This closure will be executed before actual grid instance start'
                })
            .pc-form-grid-col-60(ng-if='$ctrl.available("2.1.0")')
                +form-field__number({
                    label: 'Long query timeout:',
                    model: `${model}.longQueryWarningTimeout`,
                    name: '"LongQueryWarningTimeout"',
                    placeholder: '3000',
                    min: '0',
                    tip: 'Timeout in milliseconds after which long query warning will be printed'
                })
            .pc-form-grid-col-60(ng-if='$ctrl.available("2.7.0")')
                .ignite-form-field
                    +list-text-field({
                        items: `${model}.sqlSchemas`,
                        lbl: 'SQL schemas',
                        name: 'sqlSchemas',
                        itemName: 'schema',
                        itemsName: 'schemas'
                    })(
                    list-editable-cols=`::[{
                            name: 'SQL schemas:',
                            tip: 'SQL schemas to be created on node startup.<br/>
                            Schemas are created on local node only and are not propagated to other cluster nodes.<br/>
                            Created schemas cannot be dropped.'
                        }]`
                    )
                        +form-field__error({error: 'igniteUnique', message: 'Such property already exists!'})
            .pc-form-grid-col-60(ng-if='$ctrl.available("2.8.0")')
                +form-field__number({
                    label: 'SQL query history size:',
                    model: `${model}.sqlQueryHistorySize`,
                    name: '"sqlQueryHistorySize"',
                    placeholder: '1000',
                    min: '0',
                    tip: 'Number of SQL query history elements to keep in memory.'
                })
            .pc-form-grid-col-60(ng-if-start='$ctrl.available("2.0.0")')
                +form-field__checkbox({
                    label: 'Active on start',
                    model: model + '.activeOnStart',
                    name: '"activeOnStart"',
                    tip: 'If cluster is not active on start, there will be no cache partition map exchanges performed until the cluster is activated'
                })
            .pc-form-grid-col-60(ng-if-end)
                +form-field__checkbox({
                    label: 'Cache sanity check enabled',
                    model: model + '.cacheSanityCheckEnabled',
                    name: '"cacheSanityCheckEnabled"',
                    tip: 'If enabled, then Ignite will perform the following checks and throw an exception if check fails<br/>\
                        <ul>\
                            <li>Cache entry is not externally locked with lock or lockAsync methods when entry is enlisted to transaction</li>\
                            <li>Each entry in affinity group - lock transaction has the same affinity key as was specified on affinity transaction start</li>\
                            <li>Each entry in partition group - lock transaction belongs to the same partition as was specified on partition transaction start</li>\
                        </ul>'
                })
            .pc-form-grid-col-60(ng-if='$ctrl.available("2.4.0")')
                +form-field__checkbox({
                    label: 'Auto activation enabled',
                    model: model + '.autoActivationEnabled',
                    name: '"autoActivationEnabled"',
                    tip: 'Cluster is enabled to activate automatically when all nodes from the BaselineTopology join the cluster'
                })
            .pc-form-grid-col-60(ng-if='$ctrl.available(["1.0.0", "2.1.0"])')
                +form-field__checkbox({
                    label: 'Late affinity assignment',
                    model: model + '.lateAffinityAssignment',
                    name: '"lateAffinityAssignment"',
                    tip: 'With late affinity assignment mode if primary node was changed for some partition this nodes becomes primary only when rebalancing for all assigned primary partitions is finished'
                })
        .pca-form-column-6
            +preview-xml-java(model, 'clusterMisc', 'caches')
